package com.fyh.crud.service.imp;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fyh.crud.entity.UserEntity;
import com.fyh.crud.mapper.TestMapper;
import com.fyh.crud.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class TestServiceImp implements TestService {

    @Autowired
    private TestMapper  testMapper;

    @Override
    public IPage<UserEntity> list(int pageSize, int limit, String key) {
        Page page = new Page(pageSize,limit);
        IPage<UserEntity> list=testMapper.list(page,key);

        return list;
    }

    @Override
    public List<UserEntity> listAll() {
        List<UserEntity> list =testMapper.listAll();
        List<UserEntity> rlist = list.stream().
                                    filter(s -> s.getName().equals("张三")).
                                    collect(Collectors.toList());
        return rlist;
    }
}
